Add affine set and box section projections from JAXopt#1701
Open
discobot wants to merge 1 commit into
Open
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
8 tasks
Adds projection_affine_set and projection_box_section to optax.projections, two of the remaining items in issue 1280. Unlike their JAXopt counterparts, neither requires a QP solver: the affine set projection uses the closed-form KKT solution, and the box section projection finds the scalar dual variable by bisection wrapped in jax.lax.custom_root so it is differentiable by implicit differentiation. projection_polyhedron is left out since it depends on an OSQP-style solver, pending issue 977. Includes tests for feasibility, optimality, idempotence, consistency with projection_hyperplane and projection_simplex, and gradient correctness.
9caad96 to
22713fe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1280.
This adds
projection_affine_setandprojection_box_section, two of thethree remaining projections from the checklist.
It turns out neither needs to wait on the solver decision in #977. JAXopt's
projection_affine_setdelegates toEqualityConstrainedQP, but theequality-constrained projection has the closed-form KKT solution
p = x + aᵀ (a aᵀ)⁻¹ (b − a x), which is what's implemented here.projection_box_sectiononly needs the root of a monotone scalar function,so the bisection is done internally (the bracket
[min((lower − x)/w), max((upper − x)/w)]contains the root whenever theproblem is feasible) and is wrapped in
jax.lax.custom_root, making theprojection differentiable by implicit differentiation of the root. Both work
under
jit,vmap, andgrad. Following optax conventions, JAXopt'shyperparamstuples are flattened into named arguments, matchingprojection_hyperplaneandprojection_box.projection_polyhedronis the only item that genuinely requires anOSQP-class solver, so it is left out pending #977.
Tests check feasibility, optimality (residual orthogonal to the constraint
nullspace), idempotence, consistency with
projection_hyperplane(single-rowa) andprojection_simplex(unit weights, inactive upper bound), behaviorunder
jit, and gradients against finite differences. I also verified bothfunctions against a scipy SLSQP oracle locally (agreement ~1e-15 in float64).